python check if object is empty

46

dict1 = {}

if dict1:
    print("dict1 Not Empty")
else:
    print("dict1 is Empty")

if bool(dict1):
    print("dict1 Not Empty")
else:
    print("dict1 is Empty")

Comments

Submit
0 Comments